package cn.laixueit;

import java.util.Scanner;

public class Demo2 {
    public static void main(String[] args) {
        /*输入年、月，输出本月有多少天*/

        /* 月份 1，3，5，7，8，10，12  31天*/
        /* 月份 4,6,9,11  30天*/
        /* 2月份  28，29天*/ //是否是闰年

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入您的年份");
        int year = scanner.nextInt();
        System.out.println("请输入您的月份");
        int month = scanner.nextInt();

        String day = "";
        if(month == 1 || month == 3 || month == 5|| month == 7|| month == 8|| month == 10|| month == 12 ){
            day = "31";
        }else if(month == 4 || month == 6 || month == 9|| month == 11){
            day = "30";
        }else if(month == 2){
            if( ( year % 4 ==0 ) && (year %100 !=0) ){
                day = "29";
            }else if(year % 400 ==0){ //第二种判断
                day = "29";
            }else{
                day = "28";
            }
        }else{
            System.out.println("不好意，您输入的月份有误");
        }
        System.out.println("本月有" + day + "天");
    }
}
